using Config.Net;
using netDxf;
using netDxf.Blocks;
using netDxf.Entities;
using netDxf.Objects;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Merge
{
    class Program
    {


        static void ReadSingleDxfFile(string dxfFile)
        {
            DxfDocument srcDoc = DxfDocument.Load(dxfFile);

            foreach (Layout layout in srcDoc.Layouts)
            {

                List<DxfObject> entities = srcDoc.Layouts.GetReferences(layout)
                    .Select(r=>r.Reference).ToList();
                //Console.WriteLine(entities.Count);


                foreach (DxfObject o in entities)
                {
                    EntityObject entity = o as EntityObject;
                    if (entity != null)
                    {
                        //Console.WriteLine(entity.Type);
                        if (entity.Type == EntityType.MText)
                        {
                            MText mText = entity as MText;
                            Console.WriteLine(mText.PlainText());
                        }
                    }

                    //Console.Write(cloned + "\t");
                }
            }
            Console.WriteLine(srcDoc.DrawingVariables.AcadVer);

        }

        //static void Main(string[] args)
        //{
        //    //MergeAll();
        //    IMergeSettings settings = new ConfigurationBuilder<IMergeSettings>()
        //       .UseIniFile<IMergeSettings>("merge.ini")
        //       .Build();
        //    //settings.GridLargeHeight = 4000d;
        //    //settings.GridNormalWidth = 4000;
        //    settings.InputDirs = new string[] {@"C:\abc \f.txt","def z" };
        //    Console.WriteLine(settings.GridNormalWidth);
        //    Console.WriteLine(settings.GridLargeHeight);
        //    //ReadSingleDxfFile(@"C:\Users\YANG.LEI\Downloads\csissue\1.20 ok\2020065风冷喷雾柜 激光 ok\0.6不锈钢1套改 ok.dxf");
        //    //ReadSingleDxfFile(@"C:\Users\YANG.LEI\Downloads\newjg.dxf");
        //    Console.ReadKey();
        //}
        [STAThread]
        static void Main()
        {
            //ReadSingleDxfFile(@"C:\Users\YANG.LEI\Downloads\bug\中文测试\10盘激光图.dxf");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmMain());
            //Application.Run(new frmDrag());
            //Application.Run(new Form1());
        }
    }
}
